Skip to content

refactor(agents): Improve transfer type safety#6324

Open
mdabydeen wants to merge 2 commits into
google:mainfrom
mdabydeen:refactor/agent-transfer-typing
Open

refactor(agents): Improve transfer type safety#6324
mdabydeen wants to merge 2 commits into
google:mainfrom
mdabydeen:refactor/agent-transfer-typing

Conversation

@mdabydeen

Copy link
Copy Markdown

Created branch refactor/agent-transfer-typing and implemented the typing cleanup in src/google/ adk/flows/llm_flows/agent_transfer.py

Changes:

  • Replaced Any with BaseAgent.
  • Accepted Sequence[BaseAgent].
  • Corrected type-only imports.
  • Removed obsolete TODOs and quoted annotations.

mdabydeen added 2 commits July 7, 2026 00:23
Replace Any annotations with BaseAgent and Sequence to make transfer helper contracts explicit without changing runtime behavior.

Author: Mike Dabydeen <mdabydeen@gmail.com>
@rohityan rohityan self-assigned this Jul 9, 2026
@rohityan

rohityan commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Hi @mdabydeen , Thank you for your contribution! We appreciate you taking the time to submit this pull request.
Can you please clarify the changes.

@rohityan rohityan added the request clarification [Status] The maintainer need clarification or more information from the author label Jul 9, 2026
@mdabydeen

Copy link
Copy Markdown
Author

Hey @rohityan, appreciate you taking the time.

This PR is a small, low-risk typing cleanup in agent_transfer.py There's no behavior changes.

What changed:

  • Replaced loose Any types with the actual BaseAgent type for transfer target parameters.
  • Changed list[...] to Sequence[...] where the code only reads the collection, better reflecting intent.
  • Cleaned up TYPE_CHECKING imports to reference concrete modules (agents.base_agent, agents.llm_agent) instead of package-level re-exports.
  • Removed quoted forward-ref strings ('LlmAgent', 'BaseAgent') now that from future import annotations makes them unnecessary
  • Deleted two stale # TODO: Refactor the annotation comments that this change resolves. these functions previously accepted Any, so type checkers couldn't catch misuse of target_agent/target_agents. Now ca and the docstrings match reality instead of describing a duck-typed contract.

Risk: none functionally, this is annotations and imports only, no runtime logic touched.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

request clarification [Status] The maintainer need clarification or more information from the author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants